﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Caifu.Datas;

namespace Caifu.Services
{
	/// <summary>
	/// 基金净值业务服务
	/// </summary>
	public class NetValueService
	{
		/// <summary>
		/// 
		/// </summary>
		public static readonly NetValueService Insance = new NetValueService();

		/// <summary>
		/// 获取净值。
		/// </summary>
		/// <param name="fundId"></param>
		/// <param name="pageIndex"></param>
		/// <param name="pageSize"></param>
		/// <returns></returns>
		public static IList<NetValue> GetNetValues(Guid fundId, Int32 pageIndex, Int32 pageSize)
		{
			return NetValueData.Instance.GetNetValues(fundId, pageIndex, pageSize);
		}

		/// <summary>
		/// 获取净值。
		/// </summary>
		/// <param name="fundCode"></param>
		/// <param name="pageIndex"></param>
		/// <param name="pageSize"></param>
		/// <returns></returns>
		public static IList<NetValue> GetNetValues(string fundCode, Int32 pageIndex, Int32 pageSize)
		{
			var fund = FundService.Instance.GetFund(fundCode);
			if (fund == null) return new List<NetValue>();

			return NetValueData.Instance
				.GetNetValues(fund.Id, pageIndex, pageSize);
		}

		/// <summary>
		/// 获取指定日期的基金净值。
		/// </summary>
		/// <param name="reportDate">净值日期</param>
		/// <param name="pageIndex">当前页码</param>
		/// <param name="pageSize">每页行数</param>
		/// <returns></returns>
		public static IList<NetValue> GetNetValues(DateTime reportDate, Int32 pageIndex, Int32 pageSize)
		{
			return NetValueData.Instance.GetNetValues(reportDate, pageIndex, pageSize);
		}

		/// <summary>
		/// 获取指定日期的所有基金净值。
		/// </summary>
		/// <param name="reportDate">净值日期</param>
		/// <returns></returns>
		public static IList<NetValue> GetNetValues(DateTime reportDate)
		{
			return GetNetValues(reportDate, 1, Int32.MaxValue);
		}
	}
}
